package com.example.springboot.pojo;

import lombok.Data;

/**
 * 定义返回结果
 *
 * @Author:ChenZhangKun
 * @Date: 2021/7/25 15:22
 */
@Data
public class ResultData<T> {
    private Integer code;
    private String message;
    private T data;

    public ResultData(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public ResultData(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static ResultData success(CodeEnum codeEnum) {
        return new ResultData(codeEnum.code, codeEnum.msg);
    }

    public static ResultData success(String msg) {
        return new ResultData(CodeEnum.SUCCESS.getCode(), msg);
    }

    public  ResultData<T> success(String msg, T t) {
        return new ResultData(CodeEnum.SUCCESS.getCode(), msg, t);
    }
}
